<?php
/**
 * FastApp.
 * 8/17/24
 * @Author 深色的海 (wx:deepsea_0024)
 * @Contact telegram:deepsea159
 */

namespace App\Mall\Api\Service;

use App\Fastapp\Model\FastappCategory;
use App\Fastapp\Model\FastappTag;

class MallService
{

    public function category(): array
    {
        return ['list' => FastappCategory::query()
            ->select(['id', 'name', 'icon'])
            ->where(['scene' => 301, 'status' => 1])
            ->orderByDesc('sort')
            ->get()->map(function ($item) {
                $item->name = fastapp_lang_text($item->name);
                return $item;
            })];
    }

    public function tag(): array
    {
        return ['list' => FastappTag::query()
            ->select(['id', 'name', 'icon'])
            ->orderByDesc('sort')
            ->where(['scene' => 301, 'status' => 1])->get()->map(function ($item) {
                $item->name = fastapp_lang_text($item->name);
                return $item;
            })];
    }
}